home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / frantic.swf / scripts / CMG_AS3 / Utilities.as < prev   
Encoding:
Text File  |  2011-10-17  |  1.4 KB  |  60 lines

  1. package CMG_AS3
  2. {
  3.    import flash.external.ExternalInterface;
  4.    import flash.net.URLRequest;
  5.    import flash.net.navigateToURL;
  6.    import flash.system.Capabilities;
  7.    
  8.    public class Utilities
  9.    {
  10.        
  11.       
  12.       public function Utilities()
  13.       {
  14.          super();
  15.       }
  16.       
  17.       public static function trim(param1:String) : String
  18.       {
  19.          var _loc2_:* = undefined;
  20.          var _loc3_:* = undefined;
  21.          _loc2_ = 0;
  22.          while(param1.charCodeAt(_loc2_) < 33)
  23.          {
  24.             _loc2_++;
  25.          }
  26.          _loc3_ = param1.length - 1;
  27.          while(param1.charCodeAt(_loc3_) < 33)
  28.          {
  29.             _loc3_--;
  30.          }
  31.          return param1.substring(_loc2_,_loc3_ + 1);
  32.       }
  33.       
  34.       public static function goToUrl(param1:String) : void
  35.       {
  36.          var success:Boolean = false;
  37.          var url:String = param1;
  38.          success = false;
  39.          if(ExternalInterface.available && Capabilities.playerType != "External")
  40.          {
  41.             try
  42.             {
  43.                ExternalInterface.call("window.open",url,"win","");
  44.                success = true;
  45.             }
  46.             catch(error:Error)
  47.             {
  48.             }
  49.             catch(error:SecurityError)
  50.             {
  51.             }
  52.          }
  53.          if(success != true)
  54.          {
  55.             navigateToURL(new URLRequest(url),"_BLANK");
  56.          }
  57.       }
  58.    }
  59. }
  60.